package com.wing.productionPlan.controller.admin;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wing.common.utils.JsonResult;
import com.wing.common.utils.PageResult;
import com.wing.productionPlan.model.response.ProProductDeliveryCollectionDetailVo;
import com.wing.productionPlan.model.response.ProProductDeliveryCollectionTwoVo;
import com.wing.productionPlan.service.ProProductDeliveryOrderDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 提货订单
 *
 * @author 25923
 */
@Slf4j
@Validated
@Api(value = "Admin-提货订单详情", tags = "#/product/delivery/orderSkuCollectInfo")
@RestController("proProductDeliveryOrderCollectController")
@RequestMapping("delivery/admin/skuOrderCollect")
@RequiredArgsConstructor
public class ProProductDeliveryOrderCollectController {

    @Autowired
    private ProProductDeliveryOrderDetailService proProductDeliveryOrderDetailService;

    @ApiOperation(value = "查询提货订单列表", notes = "搜索-提货订单")
    @GetMapping("/list")
    public PageResult<ProProductDeliveryCollectionTwoVo> list(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer limit,
            @RequestParam(defaultValue = "create_time") String sort,
            @RequestParam(defaultValue = "asc") String order,
            String customerName, String purchaseCode, String skuCode, String orderNo) {
        Page<ProProductDeliveryCollectionTwoVo> pg = new Page<>(page, limit);
        Map map = new HashMap();
        map.put("customerName", customerName);
        map.put("purchaseCode", purchaseCode);
        map.put("skuCode", skuCode);
        map.put("orderNo", orderNo);
        Page<ProProductDeliveryCollectionTwoVo> list = proProductDeliveryOrderDetailService.pageListCollect4app(pg, map);
        return new PageResult<>(list.getRecords(), list.getTotal());
    }


    @ApiOperation(value = "查询提货订单列表", notes = "搜索-提货订单")
    @GetMapping("/collectList")
    public JsonResult<ProProductDeliveryCollectionDetailVo> list(
            Long customerId
            , Long productId
            , String productionLine
            , String purchaseCode
    ) {
        Map map = new HashMap();
        map.put("customerId", customerId);
        map.put("productId", productId);
        map.put("productionLine", productionLine);
        map.put("purchaseCode", purchaseCode);
        List<ProProductDeliveryCollectionDetailVo> list = proProductDeliveryOrderDetailService.collectList(map);
        JsonResult success = JsonResult.success(list);
        return success;
    }
}
